package com.twu.biblioteca;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: mini server
 * Date: 9/20/13
 * Time: 2:58 AM
 * To change this template use File | Settings | File Templates.
 */
public class MenuView implements IView
{
    public static final String WELCOME_MESSAGE = "Select one of the following options:\n";
    public static final String LOGIN_MESSAGE = "1. Login\n";
    public static final String LIST_ALL_BOOKS = "2. List All Books\n";
    public static final String RESERVE_A_BOOK = "3. Reserve A Book\n";
    public static final String CHECK_MEMBERSHIP_DETAILS = "4. Check membership details\n";
    public static final String LIST_ALL_MOVIES = "5. List All Movies\n";
    public static final String RETURN_TO_WELCOME_SCREEN = "6. Return back\n";
    public static final String QUIT = "7. Bye-Bye!\n";
    public static final String INVALID_OPTION = "Invalid choice..! Select Again..!\n";

    public static final int LIST_BOOKS = 2; // Need to try to change these to enums.
    public static final int RESERVE_BOOK = 3;
    public static final int MEMBERSHIP_DETAILS = 4;
    public static final int LIST_MOVIES = 5;
    public static final int WELCOME_SCREEN = 6;
    public static final int BYE = 7;
    public static final int LOGIN = 1;

    @Override
    public String display() {
    return MenuView.WELCOME_MESSAGE + MenuView.LOGIN_MESSAGE + MenuView.LIST_ALL_BOOKS + MenuView.RESERVE_A_BOOK +
            MenuView.CHECK_MEMBERSHIP_DETAILS + MenuView.LIST_ALL_MOVIES + MenuView.RETURN_TO_WELCOME_SCREEN + MenuView.QUIT;
    }

    @Override
    public IView interact() {
        String selectedOption;
        Scanner selectedOptionScanner = new Scanner(System.in);
        selectedOption = selectedOptionScanner.nextLine();

        switch (Integer.parseInt(selectedOption)) {
            case LOGIN:
                return new LoginView();
            case LIST_BOOKS:
                return new AllBooksView();
            case RESERVE_BOOK:
                return new ReserveABookView();
            case MEMBERSHIP_DETAILS:
                return new CheckMembershipView();
            case WELCOME_SCREEN:
                return new WelcomeView();
            case LIST_MOVIES:
                return new AllMoviesView();
            case BYE:
                return null;
            default:
                System.out.println(INVALID_OPTION);
                return this;
        }
    }
}
